﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Wedn.Web.Handler;

namespace Wedn.Web.UI.Admin.Handler
{
    /// <summary>
    /// 加载外链JavaScript执行脚本文件
    /// </summary>
    public class LoadScripts : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/x-javascript";
            string load = context.Request.QueryString["load"];
            if (load == null)
                context.Response.End();
            string dir = context.Request.QueryString["dir"] ?? "js";
            string[] styles = load.Split(',');
            string pathFormat = "/admin/resource/" + dir + "/{0}.js";
            HttpHandler.LoadResource(context, styles, pathFormat);
            //string dir = "/admin/resource/" + (rDir == null ? "js" : rDir);
            //string[] scripts = load.Split(',');
            //string searchPattern = "*.js";
            //HttpHandler.LoadResource(context, dir, searchPattern, scripts);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}